<?php
class ASyntax extends CActiveRecord
{
    public function GetSyntax($search, $currentPage, $numberRecordPerPage)
    {
        $startRecord = ($currentPage - 1) * $numberRecordPerPage;
        
        $condition = "";
        $sql = "SELECT * FROM c_config_sms WHERE 1 " . $condition . " ORDER BY type LIMIT " . $startRecord . ", " . $numberRecordPerPage;
        $command= Yii::app()->db->createCommand($sql);
        $rows = $command->queryAll();
        return $rows;
    }
    
    public function GetTotalSyntax($search)
    {
        $condition = "";
        $sql = "SELECT count(id) FROM c_config_sms WHERE 1 " . $condition;
        $command= Yii::app()->db->createCommand($sql);
        $rows = $command->queryRow();
        return $rows["count(id)"];
    }
    
    public function getSyntaxInfo($id)
    {
        $sql = "SELECT * FROM c_config_sms WHERE id=" . $id;
        $command= Yii::app()->db->createCommand($sql);
        $rows = $command->queryRow();
        return $rows;
    }
    
    public function UpdateSyntax($data)
    {
        $sql = "UPDATE c_config_sms SET 
            title=:title
            , serviceNumber=:serviceNumber
            , syntax=:syntax 
            , update_date=:update_date
            , updater=:updater
            WHERE id=:id
        ";
        $command = Yii::app()->db->createCommand($sql);
        $command->bindValues($data);
        $result = $command->execute();
        return $result;
    }
}  
?>